package org.googlecode.viewt.core.tools.dao;

import org.googlecode.viewt.core.tools.po.BasePOGenerator;
import org.googlecode.viewt.core.tools.po.POConfigUtil;

public class ConstantGenerator extends BasePOGenerator
{
  public static final String CONTEXT_PROP_DAOUTIL = "DAOUTILITY";
  private String configPath = null;

  private boolean generated = false;

  public String getConfigPath()
  {
    return this.configPath;
  }

  public void setConfigPath(String configPath)
  {
    this.configPath = configPath;
  }

  public String getLoggerCategory()
  {
    return "ConstantGenerator";
  }

  public String getPackageTemplatePath()
  {
    return "resource/template/dao";
  }

  public String getTemplate(String className)
    throws Exception
  {
    return "java_CONST.vm";
  }

  public String getOutputFile(String className)
    throws Exception
  {
    if (!(this.generated)) {
      this.generated = true;
    }
    return POConfigUtil.fullJavaFileName(getDestPath(), DAOUtils.constantClassName(className));
  }

  public boolean needGenerate(String className)
    throws Exception
  {
    return (!(this.generated));
  }

  public void setupContext()
    throws Exception
  {
    getContext().put("DAOUTILITY", new DAOUtils());
  }

  public void setupContext(String className)
    throws Exception
  {
  }

  public void cleanContext(String className)
    throws Exception
  {
  }

  public void cleanContext()
    throws Exception
  {
    getContext().remove("DAOUTILITY");
  }
}